#pragma once
#include"RedBlackTree.h"


namespace bit
{

	template<class K, class V>
	class map
	{

	public:
		struct mapKeyOfT
		{
			const K& operator()(const pair<K, V>& t)
			{
				return t.first;
			}
		};

		typedef typename RBTree<K, pair<const K, V>, mapKeyOfT>::Ierator ierator;
		typedef typename RBTree<K, pair<const K,V>, mapKeyOfT>::ConstIerator const_ierator;


	private:
		RBTree<K, pair<const K, V>, mapKeyOfT> _t;

	public:
		ierator begin()
		{
			return _t.Begin();
		}
		ierator end()
		{
			return _t.End();
		}
		const_ierator begin()const
		{
			return _t.Begin();
		}
		const_ierator end()const
		{
			return _t.End();
		}

		pair<ierator,bool> insert(const pair<K, V> data)
		{
			return _t.Insert(data);
		}
		
		V& operator[](const K& key)
		{
			pair<ierator,bool> ret =  insert(make_pair(key, V()));

			auto a = ret.first;
			auto b = a->second;

			return ret.first->second;
		}

	};


	

}